steal( 'jquery/controller',
	   'jquery/view/ejs',
	   'jquery/controller/view',
	   '<%= appPath %>/models' )
.then( './views/init.ejs', 
       './views/<%= underscore %>.ejs', 
       function($){

/**
 * @class <%=baseName%>.List
 * @parent index
 * @inherits jQuery.Controller
 * Lists <%= plural %> and lets you destroy them.
 */
$.Controller('<%=baseName%>.List',
/** @Static */
{
	defaults : {}
},
/** @Prototype */
{
	init : function(){
		this.element.html(this.view('init',<%= name %>.findAll()) )
	},
	'.destroy click': function( el ){
		if(confirm("Are you sure you want to destroy?")){
			el.closest('.<%= underscore %>').model().destroy();
		}
	},
	"{<%= name %>} destroyed" : function(<%= className %>, ev, <%= underscore %>) {
		<%= underscore %>.elements(this.element).remove();
	},
	"{<%= name %>} created" : function(<%= className %>, ev, <%= underscore %>){
		this.element.append(this.view('init', [<%= underscore %>]))
	},
	"{<%= name %>} updated" : function(<%= className %>, ev, <%= underscore %>){
		<%= underscore %>.elements(this.element)
		      .html(this.view('<%= underscore %>', <%= underscore %>) );
	}
});

});